package com.uzai.console.web.log;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.LogBizTypeEnum;
import com.uzai.console.dto.log.sysrunlog.SysRunLogQuery;
import com.uzai.console.mapper.KefuUserMapper;
import com.uzai.console.mapper.MerchantMapper;
import com.uzai.console.service.device.DeviceService;
import com.uzai.console.service.log.SysRunLogService;
import com.uzai.console.vo.log.SysRunLogBizTypeVo;
import com.uzai.console.vo.log.SysRunLogVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 运行日志
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "运行日志",tags = "查看日志|运行日志")
@ApiSort(26)
@RestController
public class SysRunLogController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(SysRunLogController.class);

    @Autowired
    private SysRunLogService sysRunLogService;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private MerchantMapper merchantMapper;
    @Autowired
    private KefuUserMapper kefuUserMapper;

    @ApiOperation(value = "查询运行日志列表", notes = "查询运行日志列表", response = SysRunLogVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/sysRunLog/findSysRunLogList")
    public Object findSysRunLogList(@RequestBody SysRunLogQuery sysRunLogQuery){
        return sysRunLogService.findSysRunLogList(sysRunLogQuery);
    }

    @ApiOperation(value = "查询设备类型下拉列表", notes = "查询设备类型下拉列表", response = SysRunLogBizTypeVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/sysRunLog/findBizTypeList")
    public Object findBizTypeList(){
        List<SysRunLogBizTypeVo> sysRunLogBizTypeVoList = new ArrayList<>();
        //先封装主账号
        LogBizTypeEnum[] logBizTypeEnums = LogBizTypeEnum.values();
        if(logBizTypeEnums != null && logBizTypeEnums.length> 0){
            for(LogBizTypeEnum logBizTypeEnum : logBizTypeEnums){
                SysRunLogBizTypeVo sysRunLogBizTypeVo = new SysRunLogBizTypeVo();
                sysRunLogBizTypeVo.setKey(logBizTypeEnum.getValue());
                sysRunLogBizTypeVo.setSecondValue(logBizTypeEnum.getDesc());
                sysRunLogBizTypeVo.setThirdValue(logBizTypeEnum.getType());
                sysRunLogBizTypeVoList.add(sysRunLogBizTypeVo);
            }
        }
        return sysRunLogBizTypeVoList;
    }

}
